import NeoVis from "neovis.js";

const neo4j = require("neo4j-driver");
let driver;

function initDriver() {
	const serverUrl = "bolt://172.20.10.11:7687";
	const serverUser = "neo4j";
	const serverPassword = "123456";    // wendu154414
	driver = neo4j.driver(serverUrl, neo4j.auth.basic(serverUser, serverPassword));
}

const config = {
	containerId: "viz",
	neo4j: driver,
	//是否显示箭头
	arrows: true,
	hierarchical: false,
	// 分层结构或者默认 "hubsize"（默认）和"directed".
	hierarchical_sort_method: 'directed',
	// hierarchical_sort_method: 'directed',
	//配置数据库查询语句，MATCH n RETURN n,尝试过不对，必须用 MATCH p=()-->() RETURN p
	labels: {
		Person: {
			label: "name",
			// community: "community",
			size: "pagerank",
			font: { size: "15", color: "#606266" }
		},
		Movie: {
			label: "title"
		}
	},
	relationships: {

	},
	initialCypher: 'MATCH (n) RETURN n LIMIT 25',			//
	visConfig: {
		edges: {
			arrows: {
				to: {
					enabled: true,
					type: "arrow",
				},
			},
			// label: "位于",
		},
	},
}

const initVis = () => {
	initDriver();
	return new NeoVis(config);
}

export default initVis;